package cn.kgc.tangcco.tcbd1011.no13.vehiclebrand.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.kgc.tangcco.tcbd1011.no13.base.action.BaseServlet;
import cn.kgc.tangcco.tcbd1011.no13.base.properties.factory.PropertiesFactory;
import cn.kgc.tangcco.tcbd1011.no13.base.util.MyBeanUtils;
import cn.kgc.tangcco.tcbd1011.no13.base.util.Utils;
import cn.kgc.tangcco.tcbd1011.no13.vehiclebrand.dao.VehicleBrandDao;
import cn.kgc.tangcco.tcbd1011.no13.vehiclebrand.entity.VehicleBrand;
import cn.kgc.tangcco.tcbd1011.no13.vehiclebrand.service.VehicleBrandService;

/**
 * Servlet implementation class VehicleBrandServlet
 */
@WebServlet(name="VehicleBrandServlet",urlPatterns="/vehicleBrand.action")
public class VehicleBrandServlet extends BaseServlet {
	private static final String SUCCESS = "vehicleBrand.action?methodName=doListVehicleBrand";

	private VehicleBrandService bservice;
	public VehicleBrandServlet() {
		bservice = (VehicleBrandService) PropertiesFactory.getInstance(Utils.VEHICLEBRANDSERVICE);
	}
	//查询所有数据
	public String doListVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = "vehicleBrand/listVehicleBrand";
		request.setAttribute("blist", bservice.queryAllVehicleBrand());
		return forward;
	}
	//去增加页面
	public String toAddVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = "vehicleBrand/addVehicleBrand";
		
		return forward;
	}
	//执行增加
	public String doAddVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = SUCCESS;
		request.setAttribute("rows", bservice.addVehicleBrand(MyBeanUtils.populate(VehicleBrand.class, request.getParameterMap())));
		return forward;
	}
	//查询单条信息
	public String detailVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = "vehicleBrand/detailVehicleBrand";
		request.setAttribute("blist", bservice.detailVehicleBrand(Utils.parseInt(request.getParameter("vehicleBrandId"))));
		return forward;
	}
	//去修改页面
	public String toUpdateVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = "vehicleBrand/updateVehicleBrand";
		request.setAttribute("blist", bservice.detailVehicleBrand(Utils.parseInt(request.getParameter("vehicleBrandId"))));
		return forward;
	}
	//执行修改操作
	public String doUpdateVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = SUCCESS;
		request.setAttribute("rows", bservice.updateVehicleBrand(MyBeanUtils.populate(VehicleBrand.class, request.getParameterMap())));
		return forward;
	}
	//删除
	public String doDeleteVehicleBrand(HttpServletRequest request,HttpServletResponse response){
		String forward = SUCCESS;
		request.setAttribute("rows", bservice.deleteVehicleBrand(Utils.parseInt(request.getParameter("vehicleBrandId"))));
		return forward;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	

}
